package com.chinamsp.codegen.config;

import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.chinamsp.codegen.CodeGenConstants;
import com.chinamsp.codegen.CodeGenProperties;
import com.chinamsp.codegen.CodeGenService;
import com.chinamsp.codegen.convert.db.DbCodeGenConfigruation;

/**
 * code gen 配置
 * @author shifenghu
 *
 */
@EnableConfigurationProperties(CodeGenProperties.class)
@Configuration
@ImportAutoConfiguration({DbCodeGenConfigruation.class})
@ConditionalOnProperty(prefix = CodeGenConstants.PROPERTIES_PREFIX, name = "output-path")
public class CodeGenConfiguration {
	
	@Bean
	public CodeGenService codeGenService(ConfigurableApplicationContext context) {
		return context.getAutowireCapableBeanFactory().createBean(CodeGenService.class);
	}
	
}
